using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;

namespace Programonica.Igramonica.LandscapeClasses
{
    public class PrimitiveList : List<Primitive>
    {
        private BoundingBox m_BoundingBox = new BoundingBox();

        public BoundingBox BoundingBox
        {
            get
            {
                return m_BoundingBox;
            }
            internal set
            {
                m_BoundingBox = value;
            }
        }

        public Vector3[] Vertexes
        {
            get
            {
                List<Vector3> vertexList = new List<Vector3>();

                foreach (Primitive tri in this)
                {
                    vertexList.Add(tri.Vertex1);
                    vertexList.Add(tri.Vertex2);
                    vertexList.Add(tri.Vertex3);
                }

                return vertexList.ToArray();
            }
        }

        public PrimitiveList()
            : base()
        {

        }

        public PrimitiveList(Primitive[] triangles)
            : base(triangles)
        {
            this.Update();
        }

        public PrimitiveList(int capacity)
            : base(capacity)
        {

        }

        public void Update()
        {
            m_BoundingBox = BoundingBox.CreateFromPoints(this.Vertexes);
        }
    }
}
